package com.elink.enginerring.redis;

import java.util.Map;

import redis.clients.jedis.Jedis;
/**
 * 获取jedis实例
 * @author Rick
 *
 */
public class JedisClient {
	private final static String host = "127.0.0.1";
	private final static int port = 6379;
//	private final static String password = "111111";

	private static Jedis jedis;
	private JedisClient() {}
	
	public static synchronized Jedis getJedis() {
		if(jedis==null||!jedis.isConnected()){
			jedis=new Jedis(host,port);
		}
		return jedis;
	}
	
	public static void main(String[] args) {
		Jedis j=getJedis();
		j.hset("testMap", "aaa", "rickaaa");
		System.out.println(j.hget("testMap", "aaa"));
		
		Map<String, String> map=j.hgetAll(RedisConstant.redis_jpush_phone_key);
		System.out.println(map.toString());
	}
}